package com.webdiy.hr.ExtDirect;

import com.google.gson.JsonArray;
import com.softwarementors.extjs.djn.config.annotations.DirectMethod;
import com.sys.plat.ExtDirect.ExtDirectBaseAction;
import com.sys.plat.util.StoreData;
import com.webdiy.dao.model.HrConfig;
import com.webdiy.hr.iface.HrConfigSerice;
import com.webdiy.hr.iface.SendEmailSerice;
import com.webdiy.hr.iface.ZhaoPinSerice;

/**
 * Created by IntelliJ IDEA.
 * User: mabo
 * Date: 2010-3-16
 * Time: 14:18:40
 * To change this template use File | Settings | File Templates.
 */
public class SendMail extends ExtDirectBaseAction {

    /**
     * 得到等待发送的职位数
     *
     * @param configId
     * @return [0]有Email的职位
     *         [1]无Email的职位
     */
    @DirectMethod
    public String[] getSendMailCount(String configId) {
        ZhaoPinSerice service = (ZhaoPinSerice) getService("ZhaoPinSericeImpl");
        return service.getSendMailCount(configId);
    }


    /**
     * 得到Email设置信息
     *
     * @param configId
     * @return [0]mail名称
     *         [1]密码
     *         [2]SMTP
     */
    @DirectMethod
    public String[] getSendMailInfo(String configId) {
        HrConfigSerice hcs = (HrConfigSerice) getService("HrConfigSericeImpl");
        return hcs.getSendMailInfo(configId);
    }

    /**
     * 保存邮箱信息
     *
     * @param hc
     */
    @DirectMethod
    public void saveSendMailInfo(HrConfig hc) {
        HrConfigSerice hcs = (HrConfigSerice) getService("HrConfigSericeImpl");
        hcs.saveSendMailInfo(hc);
    }

    /**
     * 发送Email
     *
     * @param hcId
     */
    @DirectMethod
    public void sendMail(String hcId) {
        SendEmailSerice service = (SendEmailSerice) getService("SendEmailSericeImpl");
        service.sendEmail(hcId);
    }


    /**
     * 保存网站登录信息
     * @param hc
     * @return
     */
    @DirectMethod
    public boolean saveWebInfo(HrConfig hc) {
        HrConfigSerice hcs = (HrConfigSerice) getService("HrConfigSericeImpl");
        return hcs.saveWebLoginInfo(hc);
    }

    /**
     * 得到配置信息
     * @param configId
     * @return
     */
    @DirectMethod
    public HrConfig getHrConfig(String configId) {
        HrConfigSerice hcs = (HrConfigSerice) getService("HrConfigSericeImpl");
        return hcs.editHrConfig(configId);
    }

    /**
     * 登录网站
     * @param hcId
     * @return
     */
    @DirectMethod
    public boolean loginWeb(String hcId) {
        SendEmailSerice service = (SendEmailSerice) getService("SendEmailSericeImpl");
        return service.loginWeb(hcId);
    }

    /**
     * 得到简历
     *
     * @return JSON
     */
    @DirectMethod
    public StoreData getJianLi(JsonArray params) {
        SendEmailSerice service = (SendEmailSerice) getService("SendEmailSericeImpl");
        return service.getJianLi(params.get(0).getAsJsonObject().get("hrWeb").getAsString());
    }

    /**
     * 得到求职信简历
     *
     * @return JSON
     */
    @DirectMethod
    public StoreData getQiuZhiXin(JsonArray params) {
        SendEmailSerice service = (SendEmailSerice) getService("SendEmailSericeImpl");
        return service.getQiuZhiXin(params.get(0).getAsJsonObject().get("hrWeb").getAsString());
    }
}


